﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;

namespace Web.frontpage
{
    public partial class front : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void login(object sender, EventArgs e)
        {
            string usm = username.Value;
            string pwd = password.Value;
            if (!string.IsNullOrEmpty(usm) || !string.IsNullOrEmpty(pwd))
            {
                //if (userclass.SelectedValue == "1") //即登录为学生
                //{
                    BLL.StudentService students = new BLL.StudentService();
                    BoStudents model = new BoStudents();
                    model.STU_USERNAME = usm;
                    model.STU_PASSWORD = pwd;
                    BoStudents resultModel = students.CheckStudent(model);
                    if (resultModel != null)
                    {
                        Session["studentId"] = resultModel.STU_ID;
                        Session["studentName"] = resultModel.STU_NAME;
                        Response.Redirect("SignUp/SUIndex.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert(\"用户名或者密码错误\")</script>");
                    }
                //}
                //else if (userclass.SelectedValue == "2" || userclass.SelectedValue == "3")//即管理员或者老师
                //{
                //    Response.Write("<script>alert(\"暂未开放\")</script>");
                //}
            }
            else
            {
                Response.Write("<script>alert('不允许有空项')</script>");
                return;
            }
        }
    }
}